package com.sfaug;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.TextView;

import com.sfaug.PongView.PongThread;

public class MainActivity extends Activity {
	private static final int GAME_START = 0;

/*
	private static final int REQUEST_ENABLE_BT = 1;
	private BluetoothAdapter mBtAdapter;
*/

	/** A handle to the view that is running the game */
	private PongView mPongView;
	
	/** A handle to the thread that is running the game */
	private PongThread mPongThread;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //Setup the window with no title bar        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);
        
        mPongView = (PongView)findViewById(R.id.pongView);
        mPongThread = mPongView.getThread();
        mPongView.setTextView((TextView)findViewById(R.id.text));
        
/*      
  		 //TODO: bluetooth 
        Button btnEnableBluetooth = (Button)findViewById(R.id.btnBlue);
        btnEnableBluetooth.setOnClickListener(mBtnEnableBluetoothListener);
        
        Button btnDiscover = (Button)findViewById(R.id.btnDiscover);
        btnDiscover.setOnClickListener(mBtnDiscoverListener);

        Button btnSearch = (Button)findViewById(R.id.btnSearch);
        btnSearch.setOnClickListener(mBtnSearchListener);
*/        
    }
    
    

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        menu.add(0, GAME_START, 0, R.string.start);
        return true;
	}



	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch(item.getItemId()){
		case GAME_START:
			mPongThread.doStart();
			return true;
		}
		return false;
	}

    


/*
	private OnClickListener mBtnEnableBluetoothListener =  new OnClickListener(){

		@Override
		public void onClick(View v) {
			BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
			if (mBluetoothAdapter == null) {
				Toast.makeText(MainActivity.this, "Sorry your device does not support Bluetooth", Toast.LENGTH_SHORT).show();
				System.exit(0);
			}
			if (!mBluetoothAdapter.isEnabled()) {
			    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
			    startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
			}
		}
    };
    
    private OnClickListener mBtnDiscoverListener =  new OnClickListener(){

		@Override
		public void onClick(View v) {
			
			
		}};
    
    private OnClickListener mBtnSearchListener =  new OnClickListener(){

		@Override
		public void onClick(View v) {
			// If we're already discovering, stop it
	        if (mBtAdapter.isDiscovering()) {
	            mBtAdapter.cancelDiscovery();
	        }

	        // Request discover from BluetoothAdapter
	        mBtAdapter.startDiscovery();

			
		}};
 */   
}